
const defaultState = {
    inputValue: '',
    todoArray: [1, 2, 3, 4]
}

export default (state = defaultState, action) => {
    const newState = JSON.parse(JSON.stringify(state))
    switch (action.type) {
        case 'input-change':
            newState.inputValue = action.value
            return newState
        case 'add-list':
            newState.todoArray.push(newState.inputValue)
            newState.inputValue = ''
            return newState
        case 'del-list':
            newState.todoArray.splice(action.index, 1)
            return newState
        default:
            return newState
    }
}